﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using EasyBuildingCMS.BLL.CoreEngine;

namespace EasyBuildingCMS.UserControls.Core.Utility
{
    public class EBCSiteMapDataSource:SiteMapDataSource
    {
        public EBCSiteMapDataSource()
        {
            this.Init += new System.EventHandler(this.EBC_Init);
        }

        protected void EBC_Init(object sender, EventArgs e)
        {
            int? currentPageID = BLL.Helper.ToInt(BLL.Globals.CurrentPage);

            PageRepository pageRepository = new PageRepository();
            List<string> navigationTextPath = pageRepository.GetCurrentPageNavigationUrlPath((int)currentPageID);

            this.StartingNodeUrl = navigationTextPath[0];
        }
    }
}